<?php
	include("includes/secure.php");
	include("includes/config.php");
	include("includes/class/request.class.php");
	
	$myRequest = new MyRequest();

	if( isset($_POST['add']) && $_POST['add'] == 1 ){
		$data->ban_name = trim(mysql_real_escape_string($_POST['ban_name']));		
		
		if ( $ban_code = $myRequest->addBank($data) ) {
			$bankList = $myRequest->bankList();
			$countBankList = count ($bankList);
			
			$html = '<select name="ban_code" id="ban_code" class="text_grv" onchange="javascript: chargeBankContact(this.value);">';
			$html .= '<option value="" selected="selected" disabled="disabled">Select..</option>';
			for($i=0; $i < $countBankList; $i++) {
				if ( $bankList[$i]->ban_code == $ban_code )
					$selected = 'selected';
				else
					$selected = '';
				$html .= '<option value="'.$bankList[$i]->ban_code.'" '.$selected.'>'.$bankList[$i]->ban_name.'</option>';
			}
			$html .= '<option value="-1">Other</option>';
			$html .= '</select>';
			echo ("<script> parent.reloadBanks('".$html."')</script>");
		}else
			echo "<script> parent.showCoolMessage('It could not be added the Bank.', 1) </script>";	
	}
?>